import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;


public class ProfessorPhD {
	static double a;
	static double b;
	static double[] arr = new double[8];
	static double n;
	public static void main(String[] args) throws IOException {
		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
		String linea;
		while((linea = bf.readLine())!=null){
			StringTokenizer st = new StringTokenizer(linea," ");
			a = Long.parseLong(st.nextToken());
			arr[0] = a;
			b = Long.parseLong(st.nextToken());
			arr[1] = b;
			n = Long.parseLong(st.nextToken());
			int r = (int) (n%4);
			for(int i=2; i!=8; i++){
				calcular(i);
			}
			if(n>5){
				if(r==0) System.out.println((int)arr[6]);
				if(r==1 || r==3) System.out.println((int)arr[5]);
				if(r==2) System.out.println((int)arr[4]);
			}
			else System.out.println(arr[(int) n]);
			
		
		}
	}
	
	public static double calcular(int ene){
		if(ene==0) return a;
		if(ene==1) return b;
		double res = (1+arr[ene-1])/arr[ene-2];
		return arr[ene] = res;
	}
}
